﻿@using CNKI.TPI.Web.Base
<style>
    .e-book-info span a {
        text-decoration: none;
        cursor: default;
        color: black;
    }
</style>
<div class="order-box clearfix">
    <div class="fl">
        <span class='taxis'>排序：
              @if (ViewBag.SortField != null)
              {
                  foreach (var item in ViewBag.SortField)
                  {
                      if (@ViewBag.SortFiledNow == @item.FieldName)
                      {
                  <a href="javascript:void(0);" class='cur'  onclick="sortClick('@ViewBag.SortDescAsc','@item.FieldName')">@item.FieldDispName
                      @if (@ViewBag.SortDescAsc == "desc")
                      {<i class="iconfontdesc"></i>}
                      else
                      {<i class="iconfontasc"></i>}
                  </a>
                      }
                      else
                      {
                  <a href="javascript:void(0);" onclick="sortClick('@ViewBag.SortDescAsc','@item.FieldName')">@item.FieldDispName
                  </a>
                      }

                  }
              }
        </span>
    </div>
    <div class="fr order-r">
        @if (@ViewBag.TotalPage == 0)
        {
            <span>0 条结果 0 /0</span>
        }
        else
        {
            <span>@ViewBag.ResultCount 条结果 @ViewBag.PageNow /@ViewBag.TotalPage</span>
        }

        @if (ViewBag.TotalPage > 0 && ViewBag.PageNow != ViewBag.TotalPage)
        {
            int nextpage = ViewBag.PageNow + 1;
            <a href="javascript:void(0);" class="next-t" onclick="searchPageNew('@nextpage')" ></a>
        }
        else
        {
            <a href="javascript:void(0);" class="next-t disable"></a>
        }
    </div>
</div>

<!-- e-bookSTART -->
<ul class="e-book pic-lib">

    @{ int i = 1; string classlast = "";
        int num = 5; //每行显示五个
        if (ViewBag.CategoryType != null && ViewBag.CategoryType.Count > 0)
        {
            //有分类导航
            if (SessionHelper.GetUserInfo() != null && ConfigHelper.IsShowUserHistoryEnabled()
            && ((ConfigHelper.IsAnonymousControlEnabled() && SessionHelper.GetUserInfo().UserCode.ToUpper() != ConfigHelper.GetAnonymousAccount().ToUpper())
                || !ConfigHelper.IsAnonymousControlEnabled()))
            {
                //显示历史
                num = 3;
            }
            else
            {
                //不显示历史
                num = 4;
            }
        }
        else
        {
            //无分类导航
            if (SessionHelper.GetUserInfo() != null && ConfigHelper.IsShowUserHistoryEnabled()
            && ((ConfigHelper.IsAnonymousControlEnabled() && SessionHelper.GetUserInfo().UserCode.ToUpper() != ConfigHelper.GetAnonymousAccount().ToUpper())
            || !ConfigHelper.IsAnonymousControlEnabled()))
            {
                //显示历史
                num = 4;
            }
            else
            {
                //不显示历史
                num = 5;
            }
        }
       }
    @foreach (System.Data.DataRow dr in ViewBag.SearchResult.Rows)
    {
        if (i % num == 1) //实现4个一行，4个在一个li中
        { 
        @Html.Raw("<li>")
            classlast = "";
        }
        else if (i % num == 0)
        {
            classlast = "class=e-book-last";　//如果是每行最后一个元素，则加样式
        }
        <dl @classlast>
            <dt>
                <a target="_blank"  href="@dr["SYS_FLD_URL"]">
                    <img width="224" height="168" src="@ResourceHelper.GetFirstSmallPicURL(@ViewBag.DbID, int.Parse(@dr["SYS_FLD_SYSID"].ToString()))" alt="" />
                </a>
            </dt>
            <dd class="pb10">
                <div class='tc mb10'>
                    <a target="_blank"  title="@ColumnAliasHelper.GetContent(ViewBag.SearchResult, i - 1, 0)" href="~/Detail?dbID=@ViewBag.DbID&dbName=@ViewBag.DbName&type=@ViewBag.MediaType&sysID=@dr["SYS_FLD_SYSID"].ToString()">
                        @Html.Raw(ColumnAliasHelper.SubContent(ColumnAliasHelper.GetContent(ViewBag.SearchResult, i - 1, 0), 12))</a>
                </div>
                <div class="e-book-info">
                    @*循环其他列依次显示*@
                    @{ int m = 0;
                       System.Data.DataRow columnInfo = null;
                       System.Data.DataRow[] columnInfoList = null;
                       foreach (System.Data.DataColumn column in ViewBag.SearchResult.Columns)
                       {
                           columnInfoList = ViewBag.ResultColumnInfo.Select(string.Format("Name='{0}'", column.ColumnName));
                           if (columnInfoList.Length > 0)
                           {
                               columnInfo = columnInfoList[0];
                               if (m != 0 && !column.ColumnName.StartsWith("SYS_FLD_SYSID")) //排除第一列标题列
                               {
                                   string colname = column.ColumnName;
                                   if (!string.IsNullOrEmpty(columnInfo["DispName"].ToString()))
                                   {
                                       colname = columnInfo["DispName"].ToString();
                                   }
                        <p>@colname:<span><a title="@dr[column.ColumnName].ToString()"> @Html.Raw(ColumnAliasHelper.SubContent(dr[column.ColumnName].ToString(), 15))</a></span></p>
                               }
                               m++;
                           }
                       }
                    }
                </div>
            </dd>
        </dl>
        if (i % num == 0) //实现4个一行
                       { 
        @Html.Raw("</li>")
                       }
                       i++;
    }

</ul>
@*//分页*@
<div class="pagenav pagenav-02">
    @if (ViewBag.TotalPage > 0)
    {
@*上一页*@

        if (ViewBag.PageNow != 1)
        {
            int thispage = ViewBag.PageNow - 1;
        <a href="javascript:void(0);" class="page-prev" onclick="searchPageNew('@thispage')" >上一页</a>
        }
        else
        {
        <a href="javascript:return false;" class="page-prev disable" onclick="return false">上一页</a>
        }
@*循环初始化页码*@
        foreach (string numpage in ViewBag.PageList)
        {
            if (numpage != "0")
            {
                int m = int.Parse(numpage);
                if (m == ViewBag.PageNow)
                {
        <a href="javascript:void(0);" class="active" onclick="searchPageNew('@numpage')">@numpage</a>
                    
                }
                else
                {
        <a href="javascript:void(0);" onclick="searchPageNew('@numpage')">@numpage</a>
                }

            }
            else
            {
        <i class="iconfont icon-dian2"></i>
            }

        }
@*下一页*@
        if (ViewBag.PageNow != ViewBag.TotalPage)
        {
            int nextpage = ViewBag.PageNow + 1;
        <a href="javascript:void(0);" class="page-next" onclick="searchPageNew('@nextpage')" >下一页</a>
        }
        else
        {
        <a href="javascript:return false;" class="page-prev disable" onclick="return false">下一页</a>
        }
    }
    else
    {
        <label>暂无数据！</label>

    }
</div>
